#include "gtest/gtest.h"
#include "Pile.h"
#include "Carte.h"

class PileTesteur: public ::testing::Test {
public:
	Pile<int> pile;
};

TEST_F(PileTesteur, constructeursVideOK)
{
	EXPECT_TRUE(true);
	EXPECT_TRUE(pile.estVide());
}

TEST_F(PileTesteur, empilerElement)
{
   pile.empiler(10);
   pile.empiler(20);
   pile.empiler(30);

   EXPECT_EQ(3, pile.taille());
   EXPECT_FALSE(pile.estVide());
}

TEST_F(PileTesteur, depilerElement)
{
	pile.empiler(10);
	pile.empiler(20);
	pile.empiler(30);

	EXPECT_EQ(30, pile.depiler());
	EXPECT_EQ(20, pile.depiler());
	EXPECT_EQ(10, pile.depiler());

	EXPECT_TRUE(pile.estVide());
	EXPECT_THROW(pile.depiler(),std::logic_error);
}

TEST_F(PileTesteur, Sommet)
{
	EXPECT_THROW(pile.top(),std::logic_error);

	pile.empiler(10);

	EXPECT_EQ(10, pile.top());
}

TEST_F(PileTesteur, OperateurAssignation)
{

   pile.empiler(10);
   pile.empiler(20);
   pile.empiler(30);

   Pile<int> pileCopie;
   pileCopie = pile;

   EXPECT_EQ(pile.taille(), pileCopie.taille());
   EXPECT_EQ(pile.top(), pileCopie.top());
   EXPECT_EQ(pile.depiler(), pileCopie.depiler());
   EXPECT_EQ(pile.depiler(), pileCopie.depiler());
   EXPECT_EQ(pile.depiler(), pileCopie.depiler());
}

TEST_F(PileTesteur, OperateurDAcces)
{
	pile.empiler(10);
	pile.empiler(20);
	pile.empiler(30);

	Pile<int> pileCopie;
	pileCopie = pile;

	EXPECT_EQ(pile[0], pileCopie[0]);
	EXPECT_EQ(pile[1], pileCopie[1]);
	EXPECT_EQ(pile[2], pileCopie[2]);

	EXPECT_THROW(pile[4],std::out_of_range);
}

TEST_F(PileTesteur, ConstructeurCopieOK)
{
	pile.empiler(10);
	pile.empiler(20);
	pile.empiler(30);

	Pile<int> pileCopie(pile);

	EXPECT_EQ(pile.taille(), pileCopie.taille());
	EXPECT_EQ(pile.top(), pileCopie.top());
	EXPECT_EQ(pile.depiler(), pileCopie.depiler());
	EXPECT_EQ(pile.depiler(), pileCopie.depiler());
	EXPECT_EQ(pile.depiler(), pileCopie.depiler());

}






